package com.example.demo.swagger.yanming;

import com.example.demo.annotation.MyLog;
import com.example.demo.model.BaseInfoModel;
import com.example.demo.properties.BaseInfoProps;
import com.example.demo.vo.BaseInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: YanMing.Wang
 * @date: 2024-02-28
 * @desp: 接口类:BaseInfoController,在swagger页面,tags分组展示,如果方法有tags,会单独分组(类分组和方法分组都有方法接口)
 * 如果类tags=方法tags,此时会合并去重成一个分组
 */
@Controller
@ResponseBody
@RequestMapping(value = "/swagger/baseInfo")
@Api(value = "BaseInfoController", tags = "项目信息", description = "项目基本信息的增删改查")
public class BaseInfoController {

    @Autowired
    private BaseInfoProps props;

    /**
     * 在接口中,返回值中存在实体类,他就会被扫描到swagger中
     *
     * @return
     */
    @ApiOperation(value = "接口说明:用于获取BaseInfoVO内容", notes = "详细信息:用于获取BaseInfoVO内容,包含姓名,性别,薪资信息", httpMethod = "GET")
    @RequestMapping(value = "getBaseInfoVO", method = RequestMethod.GET)
    @MyLog(value = "用于获取BaseInfoVO内容")
    public BaseInfoVO getBaseInfoVO(@RequestParam(value = "name", required = false) String name) {
        BaseInfoVO vo = new BaseInfoVO();
        vo.setName(props.getName());
        vo.setSex(props.getSex());
        vo.setSalary(props.getSalary());
        return vo;
    }

    /**
     * 在接口中,返回值中存在实体类,他就会被扫描到swagger中
     *
     * @return
     */
    @ApiOperation(value = "获取BaseInfoModel内容", notes = "查询:用于获取BaseInfoModel内容,包含姓名,性别,薪资信息", httpMethod = "GET", tags = "项目信息")
    @RequestMapping(value = "/getBaseInfoModel", method = RequestMethod.GET)
    @MyLog(value = "获取BaseInfoModel内容")
    public BaseInfoModel getBaseInfoModel() {
        BaseInfoModel model = new BaseInfoModel();
        model.setName(props.getName());
        model.setSex(props.getSex());
        model.setSalary(props.getSalary());
        return model;
    }

}
